import * as types from './types'
import Req from '../util/request'

export function setShowFeedback(showFeedback) {
	return (dispatch, getState) => {
		dispatch({
			type: types.SET_SHOW_FEEDBACK,
			showFeedback
		})
	}
}

export function sendFeedback(feedback) {
	return async (dispatch, getState) => {
		let result = await Req.post('/api/feedback', feedback)
		dispatch({
			type: types.SET_SHOW_FEEDBACK,
			showFeedback: false
		})
	}
}

export function handleMessage(message) {
	return (dispatch, getState) => {
		dispatch({
			type: types.SHOW_MESSAGE,
			message
		})
	}
}